<%-- Copyright (c) 2010 Canadensys --%>
<%@ page import="net.canadensys.dataportal.vascan.Taxon" %>
<%@ page import="net.canadensys.dataportal.vascan.VernacularName" %>
<%@ page import="net.canadensys.dataportal.utils.*" %>
<%@ include file="_inc/functions.jsp" %>
<%  String TEMPLATE_PATH = "vernacular.ftl"; %>
<%@ include file="_inc/ftl/processStart.jsp" %>
<%
try{
    int id = 0;
    if(request.getParameter("id") != null)
        id = Integer.valueOf(request.getParameter("id"));
    VernacularName vernacularName = (VernacularName) hibernateSession.load(VernacularName.class,id);

    HashMap<String,Object> data = new HashMap<String,Object>();
    
    // parents
    Taxon taxon;
    Vector<HashMap<String,Object>> vernacularNameTaxons = new Vector<HashMap<String,Object>>();
    data.put("vernacularId",vernacularName.getId());
    data.put("name",vernacularName.getName());
    data.put("reference",vernacularName.getReference().getReference());
    data.put("referenceShort",vernacularName.getReference().getReferenceshort());
    data.put("link",vernacularName.getReference().getUrl());
    data.put("language",vernacularName.getLanguage());
    data.put("status",vernacularName.getStatus().getStatus());
    // taxon vernacularName
    HashMap<String,Object> t = new HashMap<String,Object>();
    t.put("taxonId",vernacularName.getTaxon().getId());
    t.put("fullScientificName",vernacularName.getTaxon().getLookup().getCalnamehtmlauthor());
    t.put("fullScientificNameUrl",vernacularName.getTaxon().getLookup().getCalname());
    t.put("reference",vernacularName.getTaxon().getReference().getReference());
    t.put("referenceShort",vernacularName.getTaxon().getReference().getReferenceshort());
    t.put("link",vernacularName.getTaxon().getReference().getUrl());
    t.put("status",vernacularName.getTaxon().getStatus().getStatus());
    t.put("rank",vernacularName.getTaxon().getRank().getRank());
    data.put("taxon",t);
    
    // attach data to document root
    root.put("vernacularName",data);
    
    // add extra data to page global hashmap
    _page.put("isVernacular",true);
}
catch(org.hibernate.ObjectNotFoundException e){
    notFound(response);
}
catch(Exception e){
    out.write("Fatal error : " + e.toString());
}
%>
<%@ include file="_inc/ftl/processStop.jsp" %>